package com.ls.socketio.repository.dao;

import com.ls.socketio.bean.LayerInfo;
import com.ls.socketio.repository.LayerRepository;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author liShan
 * @date 2019/9/3 17:37
 */
@Component
public class LayerRepositoryImpl {

    @Resource
    private LayerRepository layerRepository;

    /**
     * 添加酒店栋数楼层
     * @param layerInfo 酒店栋数楼层
     */
    public void addLayer(LayerInfo layerInfo){
        layerRepository.save(layerInfo);
    }

    /**
     * 查询指定楼栋的层数
     * @param buildId 楼栋id
     * @return 层数
     */
    public List<LayerInfo> findByBuildId(int buildId){
        return layerRepository.findAll(
                Example.of(LayerInfo.builder().buildId(buildId).build()),
                new Sort(Sort.Direction.ASC, "layerNum"));
    }


}
